using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Deferred.Library.Scene.Graphics
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content
    /// Pipeline to read the specified data type from binary .xnb format.
    /// 
    /// Unlike the other Content Pipeline support classes, this should
    /// be a part of your main game project, and not the Content Pipeline
    /// Extension Library project.
    /// </summary>
    class DeferredModelMeshPartReader : ContentTypeReader<DeferredModelMeshPart>
    {
        protected override DeferredModelMeshPart Read(ContentReader input, DeferredModelMeshPart existingInstance)
        {
            if (existingInstance != null) return existingInstance;
            DeferredModelMeshPart instance = new DeferredModelMeshPart();

            instance.IndexBuffer = input.ReadObject<IndexBuffer>();
            instance.NormalMapName = input.ReadString();
            instance.SpecularMapName = input.ReadString();
            instance.TextureName = input.ReadString();
            instance.TriangleCount = input.ReadInt32();
            instance.VertexBuffer = input.ReadObject<VertexBuffer>();
            instance.VertexCount = input.ReadInt32();
            instance.VertexDeclaration = input.ReadObject<VertexDeclaration>();
            instance.VertexStride = input.ReadInt32();

            return instance;
        }
    }
}
